package cn.fuck;

import org.junit.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class TestStream3 {
    @Test
    public static void main(String[] args) throws IOException {
        String wordString = new String(Files.readAllBytes(Paths.get("" +
                "D:\\IDEA\\Code22\\src\\cn\\fuck\\word.txt")));
        List<String> words = Arrays.asList(wordString.split("\\W+"));
        System.out.println(words);
        System.out.println(words.size() + " words?");
        // filter的参数是只有一个抽象方法的predicate接口, 可以用lambda表达式
        Stream<String> wordsStream = words.stream().filter(w -> w.length() > 4);
        long count = wordsStream.count();
        System.out.println(count + " words length > 4");


    }
}
